package com.yang.beanfactorypostprocessor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.stereotype.Component;

/**
 * @Description: spring容器的后置处理器
 * @author: Yang Qiang
 * @create: 2021-10-23 18:56
 */
@Component
@Slf4j
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
	@Override
	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
		log.debug("spring容器后置处理器被执行了");
		AbstractBeanDefinition x = (AbstractBeanDefinition) beanFactory.getBeanDefinition("x");
		int autowireMode = x.getAutowireMode();
		x.setAutowireMode(AbstractBeanDefinition.DEPENDENCY_CHECK_SIMPLE);
		log.debug("X类的注入模型=[{}]", x.getAutowireMode());

	}
}
